/*
 * @Author: zhangshu
 * @email: shiliang.zhang@tuya.com
 * @LastEditors: Please set LastEditors
 * @file name: app_gpio_callback.c
 * @Description: 
 * @Copyright: HANGZHOU TUYA INFORMATION TECHNOLOGY CO.,LTD
 * @Company: http://www.tuya.com
 * @Date: 2022-02-08
 * @LastEditTime: 2022-02-08
 */
#include "app_common.h"
#include "app_gpio.h"
#include "app_led.h"
#include "app_ias_zone.h"
#include "tal_zigbee_local_init.h"

/*this file is for application layler callback handler*/

/**
 * @description: ias zone sensor alarm1 status active
 * @param[in] none
 * @return: none
 */
VOID_T alarm_switch_alarm1_active(VOID_T)
{
    TAL_PR_TRACE("ALARM1 trigger.\r\n");

    UINT8_T test_buf[] = {0x01,0x11,0x01};
    tal_broadcast_local_dp_value_func(1,test_buf,sizeof(test_buf)/sizeof(UINT8_T),FALSE,0,0);

    ias_zone_status_bit_set_with_report(IAS_ZONE_STATUS_BIT_ALARM_1, 1, 0);
    dev_alarm_indicate(TRUE);
}

/**
 * @description: ias zone sensor alarm1 status inactive
 * @param[in] none
 * @return: none
 */
VOID_T alarm_switch_alarm1_inactive(VOID_T)
{
    TAL_PR_TRACE("ALARM1 normal.\r\n");

    UINT8_T test_buf[] = {0x01,0x11,0x00};
    tal_broadcast_local_dp_value_func(1,test_buf,sizeof(test_buf)/sizeof(UINT8_T),FALSE,0,0);

    ias_zone_status_bit_clear_with_report(IAS_ZONE_STATUS_BIT_ALARM_1, 1, 0);
    dev_alarm_indicate(FALSE);
}

/**
 * @description: ias zone sensor tamper status active
 * @param[in] none
 * @return: none
 */
VOID_T tamper_switch_tamper_active(VOID_T)
{
    TAL_PR_TRACE("tamper trigger.\r\n");
    ias_zone_status_bit_set_with_report(IAS_ZONE_STATUS_BIT_TAMPER, 1, 0);
    dev_tamper_indicate(TRUE);
}

/**
 * @description: ias zone sensor tamper status inactive
 * @param[in] none
 * @return: none
 */
VOID_T tamper_switch_tamper_inactive(VOID_T) 
{
    TAL_PR_TRACE("tamper normal.\r\n");
    ias_zone_status_bit_clear_with_report(IAS_ZONE_STATUS_BIT_TAMPER, 1, 0);
    dev_tamper_indicate(FALSE);
}

/**
 * @description: ias zone sensor trouble status active
 * @param[in] none
 * @return: none
 */
VOID_T trouble_switch_trouble_active(VOID_T)
{
    TAL_PR_TRACE("trouble trigger.\r\n");
}

/**
 * @description: ias zone sensor trouble status inactive
 * @param[in] none
 * @return: none
 */
VOID_T trouble_switch_trouble_inactive(VOID_T) 
{
    TAL_PR_TRACE("trouble normal.\r\n");
}

